$OpenBSD: patch-lib_OpenSSL_pm,v 1.3 2015/02/27 17:24:44 jca Exp $

When requesting conversion to text format, the actual data is what has
been printed on stdout (-noout -text), not the content of the empty
file.

--- lib/OpenSSL.pm.orig	Tue Jul 25 22:12:00 2006
+++ lib/OpenSSL.pm	Thu Feb 26 18:30:58 2015
@@ -817,7 +817,7 @@ sub convdata {
    my $self = shift;
    my $opts = { @_ };
    
-   my ($tmp, $ext, $ret, $file, $pid, $cmd);
+   my ($tmp, $ext, $ret, $file, $pid, $cmd, $output);
    $file = HELPERS::mktmp($self->{'tmp'}."/data");
 
    $cmd = "$self->{'bin'} $opts->{'cmd'}";
@@ -834,10 +834,12 @@ sub convdata {
    $ext = "$cmd\n\n";
    $pid = open3($wtfh, $rdfh, $rdfh, $cmd);
    print $wtfh "$opts->{'data'}\n";
+   $output = '';
    while(<$rdfh>){
-      $ext .= $_;
+      $output .= $_;
       # print STDERR "DEBUG: cmd ret: $_";
    };
+   $ext .= $output;
    waitpid($pid, 0);
    $ret = $?>>8;
 
@@ -868,6 +870,10 @@ sub convdata {
    close(IN);
 
    unlink($file);
+
+   if($opts->{'outform'} eq 'TEXT') {
+       $tmp = $output;
+   };
 
    return($ret, $tmp, $ext);
 }
